<template>
	<view>
		<view class="passenger" @click="toPassenger">
			前往乘客
		</view>
		<view class="driver" @click="toDriver">
			前往司机
		</view>
		<view class="login" @click="toLogin">
			前往登录获取token
		</view>
		<view class="test2" @click="toTest">
			前往测试页
		</view>
		<view class="getAllOrder" @click="getAllOrder">
			获取乘客所有订单
		</view>
	</view>
</template>

<script>
	//1.导入插件
	import amapFile from '@/libs/amap-wx.js'
	import utils from "../../common/utils.js"
	import uniIcons from "@/components/uni-icons/uni-icons.vue";
	const api = utils.websiteUrl;
	export default {
		data() {
			return {
				token: ''
			}
		},
		onLoad() {
			this.token = uni.getStorageSync('token')
		},
		methods: {
			toPassenger() {
				uni.redirectTo({
					url: "/pages/index/index"
				})
			},
			toDriver() {
				uni.redirectTo({
					url: "/pages/index_driver/index_driver"
				})
			},
			toLogin() {
				uni.redirectTo({
					url: "/pages/login/login"
				})
			},
			toTest() {
				uni.redirectTo({
					url: "/pages/test2/test2"
				})
			},
			getAllOrder() {
				let that = this;
				uni.request({
					url: api + "order/getAllOrder",
					method: 'GET',
					data: {

					},
					sslVerify: false,
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
						'token': that.token
					},
					success: (res) => {
						console.log(res)
						if (res.data.code == '0') {
							console.log('获取所有订单s')
							console.log(res)
							that.haveOrder = true
							that.order = res.data.data
							that.markers = []
							let start1 = {
								id: 0,
								latitude: that.order.positionStartLatitude,
								longitude: that.order.positionStartLongitude,
								iconPath: "../../static/起点.png",
								width: 50,
								height: 50
							}
							let end1 = {
								id: 1,
								latitude: that.order.positionEndLatitude,
								longitude: that.order.positionEndLongitude,
								iconPath: "../../static/终点.png",
								width: 50,
								height: 50
							}
							that.markers.push(start1)
							that.markers.push(end1)
							that.points = []
							let start2 = {
								latitude: that.order.positionStartLatitude,
								longitude: that.order.positionStartLongitude
							}
							let end2 = {
								latitude: that.order.positionEndLatitude,
								longitude: that.order.positionEndLongitude,
							}
							that.points.push(start2)
							that.points.push(end2)
							// that.getPlanningRoute(start2, end2, 10)
						} else {
							console.log('获取所有订单e')
							console.log(res)
						}
					},
					fail: (err) => {
						console.log("获取所有订单f" + err)
					}
				})
			}
		

		}
	}
</script>

<style>

</style>